function [ fun ] = estimation_criterion(x,data_trans,B_s,B_IV,w_mat,J)

theta = reshape(x(1:size(B_s{1},2)),[size(B_s{1},2),1]);

fun = 0;

for j=1:J
    
    B_s_temp = double(B_s{j});
    B_IV_temp = double(B_IV{j});
    w_mat_temp = double(w_mat{j});
    
    error = (data_trans{j}.y - B_s_temp*theta);         % (N,1)
    %      fun_temp = error'*error;
    
    fun_temp = error'*B_IV_temp*w_mat_temp*B_IV_temp'*error;
    
    fun = fun+fun_temp;
    
end

end